package com.second.app.thread.reentrant.interrupt;

import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @author gyz
 * @date 2021/2/3 10:30
 */
public class MyService {
    private static ReentrantLock lock = new ReentrantLock();

    private final Condition condition = lock.newCondition();

    public void waitMethod() {
        lock.lock();
        try {
            System.out.println(Thread.currentThread().getName()+": 开始等待");
            condition.await();
        } catch (InterruptedException exception) {
            exception.printStackTrace();
        }
        finally {
            lock.unlock();
        }
    }

}
